{
  "info": {
    "_postman_id": "9e7c653c-4197-4adc-9878-689470b757e5",
    "name": "BluesPVA Postman Collection - alpha-v1.3.1 updated",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
    "_exporter_id": "49435118"
  },
  "item": [
    {
      "name": "PVA v2 Endpoints",
      "item": [
        {
          "name": "5. Davinci Data Export Download",
          "item": [
            {
              "name": "5.1 Davinci Data Export Download - Patient",
              "request": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{host_base_url}}/Group/davinci-data-export-download/{{download_token_Patient}}",
                  "host": [
                    "{{host_base_url}}"
                  ],
                  "path": [
                    "Group",
                    "davinci-data-export-download",
                    "{{download_token_Patient}}"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "5.2 Davinci Data Export Download - Coverage",
              "request": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{host_base_url}}/Group/davinci-data-export-download/{{download_token_Coverage}}",
                  "host": [
                    "{{host_base_url}}"
                  ],
                  "path": [
                    "Group",
                    "davinci-data-export-download",
                    "{{download_token_Coverage}}"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "5.3 Davinci Data Export Download - Consent",
              "request": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{host_base_url}}/Group/davinci-data-export-download/{{download_token_Consent}}",
                  "host": [
                    "{{host_base_url}}"
                  ],
                  "path": [
                    "Group",
                    "davinci-data-export-download",
                    "{{download_token_Consent}}"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "5.4 Davinci Data Export Download - AllergyIntolerance",
              "request": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{host_base_url}}/Group/davinci-data-export-download/{{download_token_AllergyIntolerance}}",
                  "host": [
                    "{{host_base_url}}"
                  ],
                  "path": [
                    "Group",
                    "davinci-data-export-download",
                    "{{download_token_AllergyIntolerance}}"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "5.5 Davinci Data Export Download - CarePlan",
              "request": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{host_base_url}}/Group/davinci-data-export-download/{{download_token_CarePlan}}",
                  "host": [
                    "{{host_base_url}}"
                  ],
                  "path": [
                    "Group",
                    "davinci-data-export-download",
                    "{{download_token_CarePlan}}"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "5.6 Davinci Data Export Download - CareTeam",
              "request": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{host_base_url}}/Group/davinci-data-export-download/{{download_token_CareTeam}}",
                  "host": [
                    "{{host_base_url}}"
                  ],
                  "path": [
                    "Group",
                    "davinci-data-export-download",
                    "{{download_token_CareTeam}}"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "5.7 Davinci Data Export Download - Condition",
              "request": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{host_base_url}}/Group/davinci-data-export-download/{{download_token_Condition}}",
                  "host": [
                    "{{host_base_url}}"
                  ],
                  "path": [
                    "Group",
                    "davinci-data-export-download",
                    "{{download_token_Condition}}"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "5.8 Davinci Data Export Download - Device",
              "request": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{host_base_url}}/Group/davinci-data-export-download/{{download_token_Device}}",
                  "host": [
                    "{{host_base_url}}"
                  ],
                  "path": [
                    "Group",
                    "davinci-data-export-download",
                    "{{download_token_Device}}"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "5.9 Davinci Data Export Download - DiagnosticReport",
              "request": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{host_base_url}}/Group/davinci-data-export-download/{{download_token_DiagnosticReport}}",
                  "host": [
                    "{{host_base_url}}"
                  ],
                  "path": [
                    "Group",
                    "davinci-data-export-download",
                    "{{download_token_DiagnosticReport}}"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "5.10 Davinci Data Export Download - DocumentReference",
              "request": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{host_base_url}}/Group/davinci-data-export-download/{{download_token_DocumentReference}}",
                  "host": [
                    "{{host_base_url}}"
                  ],
                  "path": [
                    "Group",
                    "davinci-data-export-download",
                    "{{download_token_DocumentReference}}"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "5.11 Davinci Data Export Download - Encounter",
              "request": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{host_base_url}}/Group/davinci-data-export-download/{{download_token_Encounter}}",
                  "host": [
                    "{{host_base_url}}"
                  ],
                  "path": [
                    "Group",
                    "davinci-data-export-download",
                    "{{download_token_Encounter}}"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "5.12 Davinci Data Export Download - Goal",
              "request": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{host_base_url}}/Group/davinci-data-export-download/{{download_token_Goal}}",
                  "host": [
                    "{{host_base_url}}"
                  ],
                  "path": [
                    "Group",
                    "davinci-data-export-download",
                    "{{download_token_Goal}}"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "5.13 Davinci Data Export Download - Immunization",
              "request": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{host_base_url}}/Group/davinci-data-export-download/{{download_token_Immunization}}",
                  "host": [
                    "{{host_base_url}}"
                  ],
                  "path": [
                    "Group",
                    "davinci-data-export-download",
                    "{{download_token_Immunization}}"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "5.14 Davinci Data Export Download - MedicationDispense",
              "request": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{host_base_url}}/Group/davinci-data-export-download/{{download_token_MedicationDispense}}",
                  "host": [
                    "{{host_base_url}}"
                  ],
                  "path": [
                    "Group",
                    "davinci-data-export-download",
                    "{{download_token_MedicationDispense}}"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "5.15 Davinci Data Export Download - MedicationRequest",
              "request": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{host_base_url}}/Group/davinci-data-export-download/{{download_token_MedicationRequest}}",
                  "host": [
                    "{{host_base_url}}"
                  ],
                  "path": [
                    "Group",
                    "davinci-data-export-download",
                    "{{download_token_MedicationRequest}}"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "5.16 Davinci Data Export Download - Observation",
              "request": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{host_base_url}}/Group/davinci-data-export-download/{{download_token_Observation}}",
                  "host": [
                    "{{host_base_url}}"
                  ],
                  "path": [
                    "Group",
                    "davinci-data-export-download",
                    "{{download_token_Observation}}"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "5.17 Davinci Data Export Download - Procedure",
              "request": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{host_base_url}}/Group/davinci-data-export-download/{{download_token_Procedure}}",
                  "host": [
                    "{{host_base_url}}"
                  ],
                  "path": [
                    "Group",
                    "davinci-data-export-download",
                    "{{download_token_Procedure}}"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "5.18 Davinci Data Export Download - Provenance",
              "request": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{host_base_url}}/Group/davinci-data-export-download/{{download_token_Provenance}}",
                  "host": [
                    "{{host_base_url}}"
                  ],
                  "path": [
                    "Group",
                    "davinci-data-export-download",
                    "{{download_token_Provenance}}"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "5.19 Davinci Data Export Download - QuestionnaireResponse",
              "request": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{host_base_url}}/Group/davinci-data-export-download/{{download_token_QuestionnaireResponse}}",
                  "host": [
                    "{{host_base_url}}"
                  ],
                  "path": [
                    "Group",
                    "davinci-data-export-download",
                    "{{download_token_QuestionnaireResponse}}"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "5.20 Davinci Data Export Download - RelatedPerson",
              "request": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{host_base_url}}/Group/davinci-data-export-download/{{download_token_RelatedPerson}}",
                  "host": [
                    "{{host_base_url}}"
                  ],
                  "path": [
                    "Group",
                    "davinci-data-export-download",
                    "{{download_token_RelatedPerson}}"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "5.21 Davinci Data Export Download - ServiceRequest",
              "request": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{host_base_url}}/Group/davinci-data-export-download/{{download_token_ServiceRequest}}",
                  "host": [
                    "{{host_base_url}}"
                  ],
                  "path": [
                    "Group",
                    "davinci-data-export-download",
                    "{{download_token_ServiceRequest}}"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "5.22 Davinci Data Export Download - Specimen",
              "request": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{host_base_url}}/Group/davinci-data-export-download/{{download_token_Specimen}}",
                  "host": [
                    "{{host_base_url}}"
                  ],
                  "path": [
                    "Group",
                    "davinci-data-export-download",
                    "{{download_token_Specimen}}"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "5.23 Davinci Data Export Download - ExplanationOfBenefit",
              "request": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{host_base_url}}/Group/davinci-data-export-download/{{download_token_ExplanationOfBenefit}}",
                  "host": [
                    "{{host_base_url}}"
                  ],
                  "path": [
                    "Group",
                    "davinci-data-export-download",
                    "{{download_token_ExplanationOfBenefit}}"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "5.24 Davinci Data Export Download - Practitioner",
              "request": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{host_base_url}}/Group/davinci-data-export-download/{{download_token_Practitioner}}",
                  "host": [
                    "{{host_base_url}}"
                  ],
                  "path": [
                    "Group",
                    "davinci-data-export-download",
                    "{{download_token_Practitioner}}"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "5.25 Davinci Data Export Download - PractitionerRole",
              "request": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{host_base_url}}/Group/davinci-data-export-download/{{download_token_PractitionerRole}}",
                  "host": [
                    "{{host_base_url}}"
                  ],
                  "path": [
                    "Group",
                    "davinci-data-export-download",
                    "{{download_token_PractitionerRole}}"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "5.26 Davinci Data Export Download - Organization",
              "request": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{host_base_url}}/Group/davinci-data-export-download/{{download_token_Organization}}",
                  "host": [
                    "{{host_base_url}}"
                  ],
                  "path": [
                    "Group",
                    "davinci-data-export-download",
                    "{{download_token_Organization}}"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "5.27 Davinci Data Export Download - Location",
              "request": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{host_base_url}}/Group/davinci-data-export-download/{{download_token_Location}}",
                  "host": [
                    "{{host_base_url}}"
                  ],
                  "path": [
                    "Group",
                    "davinci-data-export-download",
                    "{{download_token_Location}}"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "5.28 Davinci Data Export Download - Medication",
              "request": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{host_base_url}}/Group/davinci-data-export-download/{{download_token_Medication}}",
                  "host": [
                    "{{host_base_url}}"
                  ],
                  "path": [
                    "Group",
                    "davinci-data-export-download",
                    "{{download_token_Medication}}"
                  ]
                }
              },
              "response": []
            }
          ],
          "description": "One request per resource type. Step 4 saves download_token_<Type> for every file in the export manifest; requests whose type was not in the manifest are skipped automatically.",
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "// Request name ends with the resource type: \"5.x Davinci Data Export Download - <Type>\"\nconst type = pm.info.requestName.split(' - ').pop().trim();\nif (!pm.variables.get('download_token_' + type)) {\n    console.log('Skipping ' + type + ' — no file for it in the export manifest (run step 4 first).');\n    pm.execution.skipRequest();\n}\n"
                ]
              }
            },
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "const type = pm.info.requestName.split(' - ').pop().trim();\npm.test('200 OK', () => pm.response.to.have.status(200));\n\n// NDJSON: one resource per line, all of the requested type\nconst lines = pm.response.text().split('\\n').filter(l => l.trim());\npm.test(type + ' file is not empty', () => pm.expect(lines.length).to.be.above(0));\nconst bad = lines.filter(l => { try { return JSON.parse(l).resourceType !== type; } catch (e) { return true; } });\npm.test('Every line is a ' + type + ' resource', () =>\n    pm.expect(bad.length, bad.length + ' line(s) were not ' + type).to.eql(0));\nconsole.log(type + ':', lines.length, 'resource(s)');\n"
                ]
              }
            }
          ]
        },
        {
          "name": "1. Provider Member Match Kick Off",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('202 Accepted', () => pm.response.to.have.status(202));\n\n// Capture mm_task_id. Primary source: the Content-Location response header\n// (a RELATIVE path like /v2/Group/provider-member-match-status/<id>).\n// Fallbacks: a Location header, or task_id in the JSON body.\nfunction lastSegment(u) {\n    if (!u) return '';\n    let s = u.split('?')[0].split('#')[0];\n    if (s.endsWith('/')) s = s.slice(0, -1);   // tolerate trailing slash\n    return s.split('/').pop();\n}\n\nlet mm_task_id = '';\nlet source = '';\nconst loc = pm.response.headers.get('Content-Location') || pm.response.headers.get('Location');\n\nif (loc) {\n    mm_task_id = lastSegment(loc);\n    source = 'header';\n} else {\n    try {\n        const b = pm.response.json();\n        if (b && b.task_id) { mm_task_id = b.task_id; source = 'body'; }\n    } catch (e) {}\n}\n\npm.test('mm_task_id captured', () => {\n    pm.expect(mm_task_id, 'No task id found. Content-Location header was: ' + loc + '. '\n        + 'If it is missing, the gateway (FITE) did not forward it — the service must emit a RELATIVE Content-Location.')\n        .to.be.a('string').and.not.empty;\n});\n\nif (mm_task_id) {\n    pm.collectionVariables.set('mm_task_id', mm_task_id);\n    // Environment variables take precedence over collection variables — keep them in sync\n    if (pm.environment.name) pm.environment.set('mm_task_id', mm_task_id);\n    console.log('mm_task_id:', mm_task_id, '(from', source, ')');\n} else {\n    console.error('[A2] mm_task_id NOT captured. Content-Location:', loc, '| body:', pm.response.text());\n}\n"
                ]
              }
            }
          ],
          "protocolProfileBehavior": {
            "disabledSystemHeaders": {
              "accept": true,
              "content-type": true
            }
          },
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/fhir+json"
              },
              {
                "key": "Prefer",
                "value": "respond-async"
              },
              {
                "key": "scope",
                "value": "system/Patient.read",
                "disabled": true
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"resourceType\": \"Parameters\",\n  \"meta\": { \"profile\": [ \"http://hl7.org/fhir/us/davinci-pdex/StructureDefinition/provider-parameters-multi-member-match-bundle-in\" ] },\n  \"parameter\": [\n    {\n      \"name\": \"MemberBundle\",\n      \"part\": [\n        { \"name\": \"MemberPatient\", \"resource\": { \"resourceType\": \"Patient\", \"id\": \"ptloc1\", \"name\": [ { \"family\": \"Local\", \"given\": [ \"Laura\" ] } ], \"gender\": \"female\", \"birthDate\": \"1985-04-12\" } },\n        { \"name\": \"CoverageToMatch\", \"resource\": {\n            \"resourceType\": \"Coverage\", \"id\": \"covloc1\", \"status\": \"active\",\n            \"identifier\": [ { \"type\": { \"coding\": [ { \"system\": \"http://terminology.hl7.org/CodeSystem/v2-0203\", \"code\": \"MB\", \"display\": \"Member Number\" } ] }, \"system\": \"http://example.org/payer/member-id\", \"value\": \"LOC00001\" } ],\n            \"subscriberId\": \"LOC00001\",\n            \"relationship\": { \"coding\": [ { \"system\": \"http://terminology.hl7.org/CodeSystem/subscriber-relationship\", \"code\": \"self\" } ] },\n            \"beneficiary\": { \"identifier\": { \"system\": \"http://example.org/payer/member-id\", \"value\": \"LOC00001\" } },\n            \"payor\": [ { \"identifier\": { \"system\": \"http://hl7.org/fhir/sid/us-npi\", \"value\": \"1003100000\" } } ] } },\n        { \"name\": \"Consent\", \"resource\": {\n            \"resourceType\": \"Consent\", \"id\": \"attloc1\", \"status\": \"active\",\n            \"scope\": { \"coding\": [ { \"system\": \"http://terminology.hl7.org/CodeSystem/consentscope\", \"code\": \"patient-privacy\" } ] },\n            \"category\": [ { \"coding\": [ { \"system\": \"http://terminology.hl7.org/CodeSystem/v3-ActCode\", \"code\": \"IDSCL\" } ] } ],\n            \"patient\": { \"identifier\": { \"system\": \"http://example.org/payer/member-id\", \"value\": \"LOC00001\" } },\n            \"dateTime\": \"2024-03-01T00:00:00Z\",\n            \"performer\": [ { \"identifier\": { \"system\": \"http://hl7.org/fhir/sid/us-npi\", \"value\": \"1004000000\" } } ],\n            \"policy\": [ { \"uri\": \"http://example.org/pva/attestation-policy\" } ] } }\n      ]\n    },\n    {\n      \"name\": \"MemberBundle\",\n      \"part\": [\n        { \"name\": \"MemberPatient\", \"resource\": { \"resourceType\": \"Patient\", \"id\": \"ptloc2\", \"name\": [ { \"family\": \"Local\", \"given\": [ \"Liam\" ] } ], \"gender\": \"male\", \"birthDate\": \"1978-11-30\" } },\n        { \"name\": \"CoverageToMatch\", \"resource\": {\n            \"resourceType\": \"Coverage\", \"id\": \"covloc2\", \"status\": \"active\",\n            \"identifier\": [ { \"type\": { \"coding\": [ { \"system\": \"http://terminology.hl7.org/CodeSystem/v2-0203\", \"code\": \"MB\", \"display\": \"Member Number\" } ] }, \"system\": \"http://example.org/payer/member-id\", \"value\": \"LOC00002\" } ],\n            \"subscriberId\": \"LOC00002\",\n            \"relationship\": { \"coding\": [ { \"system\": \"http://terminology.hl7.org/CodeSystem/subscriber-relationship\", \"code\": \"self\" } ] },\n            \"beneficiary\": { \"identifier\": { \"system\": \"http://example.org/payer/member-id\", \"value\": \"LOC00002\" } },\n            \"payor\": [ { \"identifier\": { \"system\": \"http://hl7.org/fhir/sid/us-npi\", \"value\": \"1003100000\" } } ] } },\n        { \"name\": \"Consent\", \"resource\": {\n            \"resourceType\": \"Consent\", \"id\": \"attloc2\", \"status\": \"active\",\n            \"scope\": { \"coding\": [ { \"system\": \"http://terminology.hl7.org/CodeSystem/consentscope\", \"code\": \"patient-privacy\" } ] },\n            \"category\": [ { \"coding\": [ { \"system\": \"http://terminology.hl7.org/CodeSystem/v3-ActCode\", \"code\": \"IDSCL\" } ] } ],\n            \"patient\": { \"identifier\": { \"system\": \"http://example.org/payer/member-id\", \"value\": \"LOC00002\" } },\n            \"dateTime\": \"2024-03-01T00:00:00Z\",\n            \"performer\": [ { \"identifier\": { \"system\": \"http://hl7.org/fhir/sid/us-npi\", \"value\": \"1004000000\" } } ],\n            \"policy\": [ { \"uri\": \"http://example.org/pva/attestation-policy\" } ] } }\n      ]\n    },\n    {\n      \"name\": \"MemberBundle\",\n      \"part\": [\n        { \"name\": \"MemberPatient\", \"resource\": { \"resourceType\": \"Patient\", \"id\": \"ptloc3\", \"name\": [ { \"family\": \"Local\", \"given\": [ \"Lucia\" ] } ], \"gender\": \"female\", \"birthDate\": \"1992-02-05\" } },\n        { \"name\": \"CoverageToMatch\", \"resource\": {\n            \"resourceType\": \"Coverage\", \"id\": \"covloc3\", \"status\": \"active\",\n            \"identifier\": [ { \"type\": { \"coding\": [ { \"system\": \"http://terminology.hl7.org/CodeSystem/v2-0203\", \"code\": \"MB\", \"display\": \"Member Number\" } ] }, \"system\": \"http://example.org/payer/member-id\", \"value\": \"LOC00003\" } ],\n            \"subscriberId\": \"LOC00003\",\n            \"relationship\": { \"coding\": [ { \"system\": \"http://terminology.hl7.org/CodeSystem/subscriber-relationship\", \"code\": \"self\" } ] },\n            \"beneficiary\": { \"identifier\": { \"system\": \"http://example.org/payer/member-id\", \"value\": \"LOC00003\" } },\n            \"payor\": [ { \"identifier\": { \"system\": \"http://hl7.org/fhir/sid/us-npi\", \"value\": \"1003100000\" } } ] } },\n        { \"name\": \"Consent\", \"resource\": {\n            \"resourceType\": \"Consent\", \"id\": \"attloc3\", \"status\": \"active\",\n            \"scope\": { \"coding\": [ { \"system\": \"http://terminology.hl7.org/CodeSystem/consentscope\", \"code\": \"patient-privacy\" } ] },\n            \"category\": [ { \"coding\": [ { \"system\": \"http://terminology.hl7.org/CodeSystem/v3-ActCode\", \"code\": \"IDSCL\" } ] } ],\n            \"patient\": { \"identifier\": { \"system\": \"http://example.org/payer/member-id\", \"value\": \"LOC00003\" } },\n            \"dateTime\": \"2024-03-01T00:00:00Z\",\n            \"performer\": [ { \"identifier\": { \"system\": \"http://hl7.org/fhir/sid/us-npi\", \"value\": \"1004000000\" } } ],\n            \"policy\": [ { \"uri\": \"http://example.org/pva/attestation-policy\" } ] } }\n      ]\n    },\n    {\n      \"name\": \"MemberBundle\",\n      \"part\": [\n        { \"name\": \"MemberPatient\", \"resource\": { \"resourceType\": \"Patient\", \"id\": \"ptnon1\", \"name\": [ { \"family\": \"Nonlocal\", \"given\": [ \"Nina\" ] } ], \"gender\": \"female\", \"birthDate\": \"1990-03-15\" } },\n        { \"name\": \"CoverageToMatch\", \"resource\": {\n            \"resourceType\": \"Coverage\", \"id\": \"covnon1\", \"status\": \"active\",\n            \"identifier\": [ { \"type\": { \"coding\": [ { \"system\": \"http://terminology.hl7.org/CodeSystem/v2-0203\", \"code\": \"MB\", \"display\": \"Member Number\" } ] }, \"system\": \"http://example.org/payer/member-id\", \"value\": \"NON00001\" } ],\n            \"subscriberId\": \"NON00001\",\n            \"relationship\": { \"coding\": [ { \"system\": \"http://terminology.hl7.org/CodeSystem/subscriber-relationship\", \"code\": \"self\" } ] },\n            \"beneficiary\": { \"identifier\": { \"system\": \"http://example.org/payer/member-id\", \"value\": \"NON00001\" } },\n            \"payor\": [ { \"identifier\": { \"system\": \"http://hl7.org/fhir/sid/us-npi\", \"value\": \"1003100000\" } } ] } },\n        { \"name\": \"Consent\", \"resource\": {\n            \"resourceType\": \"Consent\", \"id\": \"attnon1\", \"status\": \"active\",\n            \"scope\": { \"coding\": [ { \"system\": \"http://terminology.hl7.org/CodeSystem/consentscope\", \"code\": \"patient-privacy\" } ] },\n            \"category\": [ { \"coding\": [ { \"system\": \"http://terminology.hl7.org/CodeSystem/v3-ActCode\", \"code\": \"IDSCL\" } ] } ],\n            \"patient\": { \"identifier\": { \"system\": \"http://example.org/payer/member-id\", \"value\": \"NON00001\" } },\n            \"dateTime\": \"2024-03-01T00:00:00Z\",\n            \"performer\": [ { \"identifier\": { \"system\": \"http://hl7.org/fhir/sid/us-npi\", \"value\": \"1004000000\" } } ],\n            \"policy\": [ { \"uri\": \"http://example.org/pva/attestation-policy\" } ] } }\n      ]\n    },\n    {\n      \"name\": \"MemberBundle\",\n      \"part\": [\n        { \"name\": \"MemberPatient\", \"resource\": { \"resourceType\": \"Patient\", \"id\": \"ptnon2\", \"name\": [ { \"family\": \"Nonlocal\", \"given\": [ \"Oscar\" ] } ], \"gender\": \"male\", \"birthDate\": \"1982-07-22\" } },\n        { \"name\": \"CoverageToMatch\", \"resource\": {\n            \"resourceType\": \"Coverage\", \"id\": \"covnon2\", \"status\": \"active\",\n            \"identifier\": [ { \"type\": { \"coding\": [ { \"system\": \"http://terminology.hl7.org/CodeSystem/v2-0203\", \"code\": \"MB\", \"display\": \"Member Number\" } ] }, \"system\": \"http://example.org/payer/member-id\", \"value\": \"NON00002\" } ],\n            \"subscriberId\": \"NON00002\",\n            \"relationship\": { \"coding\": [ { \"system\": \"http://terminology.hl7.org/CodeSystem/subscriber-relationship\", \"code\": \"self\" } ] },\n            \"beneficiary\": { \"identifier\": { \"system\": \"http://example.org/payer/member-id\", \"value\": \"NON00002\" } },\n            \"payor\": [ { \"identifier\": { \"system\": \"http://hl7.org/fhir/sid/us-npi\", \"value\": \"1003100000\" } } ] } },\n        { \"name\": \"Consent\", \"resource\": {\n            \"resourceType\": \"Consent\", \"id\": \"attnon2\", \"status\": \"active\",\n            \"scope\": { \"coding\": [ { \"system\": \"http://terminology.hl7.org/CodeSystem/consentscope\", \"code\": \"patient-privacy\" } ] },\n            \"category\": [ { \"coding\": [ { \"system\": \"http://terminology.hl7.org/CodeSystem/v3-ActCode\", \"code\": \"IDSCL\" } ] } ],\n            \"patient\": { \"identifier\": { \"system\": \"http://example.org/payer/member-id\", \"value\": \"NON00002\" } },\n            \"dateTime\": \"2024-03-01T00:00:00Z\",\n            \"performer\": [ { \"identifier\": { \"system\": \"http://hl7.org/fhir/sid/us-npi\", \"value\": \"1004000000\" } } ],\n            \"policy\": [ { \"uri\": \"http://example.org/pva/attestation-policy\" } ] } }\n      ]\n    }\n  ]\n}\n",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{host_base_url}}/Group/$provider-member-match",
              "host": [
                "{{host_base_url}}"
              ],
              "path": [
                "Group",
                "$provider-member-match"
              ]
            }
          },
          "response": []
        },
        {
          "name": "2. Provider Member Match Status Check",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "// Status returns 202 while the job is running, 200 with the output list once done\r\nif (pm.response.code === 202) {\r\n    console.log('Match job still in progress — send the status request again.');\r\n    return;\r\n}\r\n\r\npm.test('200 OK', () => pm.response.to.have.status(200));\r\n\r\nlet body = {};\r\ntry { body = pm.response.json(); } catch (e) {}\r\nconst output = (body && body.output) || [];\r\n\r\n// File name in the url → variable name to save it as\r\nconst targets = {\r\n    'MatchedMembers.ndjson':            'matched_members_url',\r\n    'NonMatchedMembers.ndjson':         'non_matched_members_url',\r\n    'ConsentConstrainedMembers.ndjson': 'consent_constrained_members_url',\r\n    '_member_match.ndjson':             'member_match_parameters_url'\r\n};\r\n\r\nfunction save(name, value) {\r\n    pm.collectionVariables.set(name, value);\r\n    // Environment variables take precedence over collection variables — keep them in sync\r\n    if (pm.environment.name) pm.environment.set(name, value);\r\n}\r\n\r\noutput.forEach(o => {\r\n    const url = o.url || '';\r\n    const file = url.split('?')[0].split('/').pop();\r\n    // Check exact file names first, then the _member_match suffix\r\n    // ('NonMatchedMembers.ndjson' also ends with 'MatchedMembers.ndjson', so compare the full name)\r\n    const key = targets[file] ? file\r\n              : (file.endsWith('_member_match.ndjson') ? '_member_match.ndjson' : null);\r\n    if (key) {\r\n        save(targets[key], url);\r\n        console.log(targets[key] + ':', url);\r\n    }\r\n});\r\n\r\npm.test('Output contains Matched / NonMatched / ConsentConstrained urls', () => {\r\n    pm.expect(pm.variables.get('matched_members_url'), 'matched_members_url').to.be.a('string').and.not.empty;\r\n    pm.expect(pm.variables.get('non_matched_members_url'), 'non_matched_members_url').to.be.a('string').and.not.empty;\r\n    pm.expect(pm.variables.get('consent_constrained_members_url'), 'consent_constrained_members_url').to.be.a('string').and.not.empty;\r\n});\r\n\r\npm.test('No errors reported', () => pm.expect(body.error || []).to.be.empty);\r\n"
                ]
              }
            }
          ],
          "protocolProfileBehavior": {
            "disableBodyPruning": true
          },
          "request": {
            "method": "GET",
            "header": [],
            "body": {
              "mode": "raw",
              "raw": "",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{host_base_url}}/Group/provider-member-match-status/{{mm_task_id}}",
              "host": [
                "{{host_base_url}}"
              ],
              "path": [
                "Group",
                "provider-member-match-status",
                "{{mm_task_id}}"
              ]
            }
          },
          "response": []
        },
        {
          "name": "2.1 Matched Member Group Check",
          "protocolProfileBehavior": {
            "disableBodyPruning": true
          },
          "request": {
            "method": "GET",
            "header": [],
            "body": {
              "mode": "raw",
              "raw": "",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{matched_members_url}}",
              "host": [
                "{{matched_members_url}}"
              ]
            }
          },
          "response": []
        },
        {
          "name": "2.2 Non Matched Member Group Check",
          "protocolProfileBehavior": {
            "disableBodyPruning": true
          },
          "request": {
            "method": "GET",
            "header": [],
            "body": {
              "mode": "raw",
              "raw": "",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{non_matched_members_url}}",
              "host": [
                "{{non_matched_members_url}}"
              ]
            }
          },
          "response": []
        },
        {
          "name": "2.3 Consent Constrain Member Group Check",
          "protocolProfileBehavior": {
            "disableBodyPruning": true
          },
          "request": {
            "method": "GET",
            "header": [],
            "body": {
              "mode": "raw",
              "raw": "",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{consent_constrained_members_url}}",
              "host": [
                "{{consent_constrained_members_url}}"
              ]
            }
          },
          "response": []
        },
        {
          "name": "2.4 Parameter Combined Response",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "// Extract group_id from the MatchedMembers Group resource in the Parameters response\nlet group_id = '';\ntry {\n    const body = pm.response.json();\n    // Response is a FHIR Parameters resource — iterate body.parameter (not body.entry)\n    const params = body.parameter || [];\n    const matchedParam = params.find(p =>\n        p.name === 'MatchedMembers' &&\n        p.resource &&\n        p.resource.resourceType === 'Group'\n    );\n    if (matchedParam) {\n        group_id = matchedParam.resource.id;\n    }\n} catch (e) {\n    console.error('Failed to parse response body for group_id:', e);\n}\n\npm.test('group_id captured', () => {\n    pm.expect(group_id, 'No group_id found in MatchedMembers Group parameter').to.be.a('string').and.not.empty;\n});\n\nif (group_id) {\n    pm.collectionVariables.set('group_id', group_id);\n    // Environment variables take precedence over collection variables — keep them in sync\n    if (pm.environment.name) pm.environment.set('group_id', group_id);\n    console.log('group_id:', group_id);\n} else {\n    console.error('group_id NOT captured. Response body:', pm.response.text());\n}"
                ]
              }
            }
          ],
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{host_base_url}}/Group/provider-member-match-response/{{mm_task_id}}",
              "host": [
                "{{host_base_url}}"
              ],
              "path": [
                "Group",
                "provider-member-match-response",
                "{{mm_task_id}}"
              ]
            }
          },
          "response": []
        },
        {
          "name": "3. Davinci Data Export Kick Off",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('202 Accepted', () => pm.response.to.have.status(202));\n\n// Capture export_task_id. Primary source: the Content-Location response header\n// (a RELATIVE path like /v2/Group/davinci-data-export-status/<id>).\n// Fallbacks: a Location header, or task_id in the JSON body.\nfunction lastSegment(u) {\n    if (!u) return '';\n    let s = u.split('?')[0].split('#')[0];\n    if (s.endsWith('/')) s = s.slice(0, -1);   // tolerate trailing slash\n    return s.split('/').pop();\n}\n\nlet export_task_id = '';\nlet source = '';\nconst loc = pm.response.headers.get('Content-Location') || pm.response.headers.get('Location');\n\nif (loc) {\n    export_task_id = lastSegment(loc);\n    source = 'header';\n} else {\n    try {\n        const b = pm.response.json();\n        if (b && b.task_id) { export_task_id = b.task_id; source = 'body'; }\n    } catch (e) {}\n}\n\npm.test('export_task_id captured', () => {\n    pm.expect(export_task_id, 'No task id found. Content-Location header was: ' + loc + '. '\n        + 'If it is missing, the gateway (FITE) did not forward it — the service must emit a RELATIVE Content-Location.')\n        .to.be.a('string').and.not.empty;\n});\n\nif (export_task_id) {\n    pm.collectionVariables.set('export_task_id', export_task_id);\n    // Environment variables take precedence over collection variables — keep them in sync\n    if (pm.environment.name) pm.environment.set('export_task_id', export_task_id);\n    console.log('export_task_id:', export_task_id, '(from', source, ')');\n} else {\n    console.error('[EXPORT] export_task_id NOT captured. Content-Location:', loc, '| body:', pm.response.text());\n}\n"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Prefer",
                "value": "respond-async"
              },
              {
                "key": "Content-Type",
                "value": "application/fhir+json"
              },
              {
                "key": "Accept",
                "value": "application/fhir+json",
                "disabled": true
              },
              {
                "key": "",
                "value": "",
                "disabled": true
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\r\n  \"resourceType\": \"Parameters\",\r\n  \"parameter\": [\r\n    {\r\n      \"name\": \"exportType\",\r\n      \"valueString\": \"hl7.fhir.us.davinci-pdex#provider-snapshot\"\r\n    }\r\n  ]\r\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{host_base_url}}/Group/{{group_id}}/$davinci-data-export",
              "host": [
                "{{host_base_url}}"
              ],
              "path": [
                "Group",
                "{{group_id}}",
                "$davinci-data-export"
              ]
            }
          },
          "response": []
        },
        {
          "name": "4. Davinci Data Export Status",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "// 202 = export still running; the manifest only comes with 200\nif (pm.response.code === 202) {\n    console.log('Export in progress (X-Progress:', pm.response.headers.get('X-Progress'), ') — send status again.');\n    return;\n}\npm.test('200 OK', () => pm.response.to.have.status(200));\n\n// Every type the export can emit — one \"5.x Download\" request exists per type\nconst TYPES = [\"Patient\", \"Coverage\", \"Consent\", \"AllergyIntolerance\", \"CarePlan\", \"CareTeam\", \"Condition\", \"Device\", \"DiagnosticReport\", \"DocumentReference\", \"Encounter\", \"Goal\", \"Immunization\", \"MedicationDispense\", \"MedicationRequest\", \"Observation\", \"Procedure\", \"Provenance\", \"QuestionnaireResponse\", \"RelatedPerson\", \"ServiceRequest\", \"Specimen\", \"ExplanationOfBenefit\", \"Practitioner\", \"PractitionerRole\", \"Organization\", \"Location\", \"Medication\"];\n\nfunction lastSegment(u) {\n    if (!u) return '';\n    let s = u.split('?')[0].split('#')[0];\n    if (s.endsWith('/')) s = s.slice(0, -1);\n    return s.split('/').pop();\n}\nfunction save(name, value) {\n    pm.collectionVariables.set(name, value);\n    // Environment variables take precedence over collection variables — keep them in sync\n    if (pm.environment.name) pm.environment.set(name, value);\n}\n\n// Clear tokens from a previous export so a type missing from this manifest is skipped, not downloaded stale\nTYPES.forEach(t => save('download_token_' + t, ''));\n\nlet outputs = [];\ntry {\n    const body = pm.response.json();\n    outputs = body.output || [];\n} catch (e) {\n    console.error('Failed to parse response body for download tokens:', e);\n}\n\n// One token per resource type: download_token_Patient, download_token_Coverage, ...\nconst tokens = {};\noutputs.forEach(o => {\n    const t = lastSegment(o.url);\n    if (t && o.type) {\n        tokens[o.type] = t;\n        save('download_token_' + o.type, t);\n        if (!TYPES.includes(o.type)) console.warn('No download request exists for type', o.type, '— token saved as download_token_' + o.type);\n    }\n});\n\npm.test('download tokens captured', () => {\n    pm.expect(Object.keys(tokens), 'No download tokens found in output[].url').to.not.be.empty;\n});\nconsole.log('Download tokens (' + Object.keys(tokens).length + ' types):', tokens);\n"
                ]
              }
            }
          ],
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{host_base_url}}/Group/davinci-data-export-status/{{export_task_id}}",
              "host": [
                "{{host_base_url}}"
              ],
              "path": [
                "Group",
                "davinci-data-export-status",
                "{{export_task_id}}"
              ]
            }
          },
          "response": []
        }
      ]
    },
    {
      "name": "Blues Home API Endpoints",
      "item": [
        {
          "name": "Nonlocal Nina — Match",
          "item": [
            {
              "name": "1. $member-match — 200 match",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "type": "text/javascript",
                    "exec": [
                      "pm.test('200 OK', () => pm.response.to.have.status(200));\nconst body = pm.response.json();\npm.test('FHIR Parameters', () => pm.expect(body.resourceType).to.eql('Parameters'));\n\nconst memberId = body.parameter && body.parameter.find(p => p.name === 'MemberId');\npm.test('MemberId parameter present', () => pm.expect(memberId, 'no MemberId param in response').to.not.be.undefined);\n\nconst ref = memberId && memberId.valueReference && memberId.valueReference.reference;\npm.test('MemberId.valueReference contains Patient/{id}', () => pm.expect(ref).to.match(/\\/?Patient\\/[^/]+$/));\n\n// Supports both relative (Patient/{id}) and absolute (https://.../Patient/{id}) refs.\nif (ref) {\n    const patientId = ref.replace(/.*\\/?Patient\\//, '');\n    pm.collectionVariables.set('nina_patient_id', patientId);\n    console.log('nina_patient_id =', patientId);\n}"
                    ]
                  }
                }
              ],
              "request": {
                "method": "POST",
                "header": [
                  {
                    "key": "Content-Type",
                    "value": "application/fhir+json"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"resourceType\": \"Parameters\",\n  \"parameter\": [\n    {\n      \"name\": \"MemberPatient\",\n      \"resource\": {\n        \"resourceType\": \"Patient\",\n        \"name\": [ { \"family\": \"Nonlocal\", \"given\": [ \"Nina\" ] } ],\n        \"gender\": \"female\",\n        \"birthDate\": \"1990-03-15\"\n      }\n    },\n    {\n      \"name\": \"CoverageToMatch\",\n      \"resource\": {\n        \"resourceType\": \"Coverage\",\n        \"status\": \"active\",\n        \"identifier\": [\n          {\n            \"type\": {\n              \"coding\": [\n                {\n                  \"system\": \"http://terminology.hl7.org/CodeSystem/v2-0203\",\n                  \"code\": \"MB\",\n                  \"display\": \"Member Number\"\n                }\n              ]\n            },\n            \"system\": \"http://example.org/payer/member-id\",\n            \"value\": \"NON00001\"\n          }\n        ],\n        \"subscriberId\": \"NON00001\",\n        \"relationship\": { \"coding\": [ { \"system\": \"http://terminology.hl7.org/CodeSystem/subscriber-relationship\", \"code\": \"self\" } ] },\n        \"beneficiary\": { \"reference\": \"Patient/flowc-nonlocal-9001\", \"display\": \"Nina Nonlocal\" },\n        \"payor\": [ { \"identifier\": { \"system\": \"http://hl7.org/fhir/sid/us-npi\", \"value\": \"1003100000\" } } ]\n      }\n    }\n  ]\n}\n",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                },
                "url": {
                  "raw": "{{home_base_url}}/Patient/$member-match",
                  "host": [
                    "{{home_base_url}}"
                  ],
                  "path": [
                    "Patient",
                    "$member-match"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "2. $everything — 200 Bundle",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "type": "text/javascript",
                    "exec": [
                      "pm.test('200 OK', () => pm.response.to.have.status(200));\nconst body = pm.response.json();\npm.test('FHIR Bundle', () => pm.expect(body.resourceType).to.eql('Bundle'));\npm.test('searchset type', () => pm.expect(body.type).to.eql('searchset'));\n\n// Page 1 = the original request (no _page_token); later pages come from {{next_link}}\nconst isFirstPage = !pm.request.url.toString().includes('_page_token');\n\n// Only page 1 is guaranteed to carry the Patient; later pages hold the remaining resources\nif (isFirstPage) {\n    const hasPatient = (body.entry || []).some(e => e.resource && e.resource.resourceType === 'Patient');\n    pm.test('Bundle includes the Patient resource', () => pm.expect(hasPatient).to.be.true);\n}\n\n// ---- Pagination: save the next link exactly as the server returns it ----\nfunction save(name, value) {\n    pm.collectionVariables.set(name, value);\n    // Environment variables take precedence over collection variables — keep them in sync\n    if (pm.environment.name) pm.environment.set(name, value);\n}\nfunction clear(name) {\n    pm.collectionVariables.unset(name);\n    if (pm.environment.name) pm.environment.unset(name);\n}\n\nconst next = (body.link || []).find(l => l.relation === 'next');\nconst next_link = next && next.url ? next.url : '';\n\n// Running total of entries across pages\nconst soFar = isFirstPage ? 0 : Number(pm.collectionVariables.get('everything_entry_total') || 0);\nconst total = soFar + (body.entry || []).length;\nsave('everything_entry_total', String(total));\n\nif (next_link) {\n    save('next_link', next_link);\n    console.log('next_link:', next_link, '| entries so far:', total);\n} else {\n    clear('next_link');\n    console.log('No next link — last page reached. Total entries:', total);\n}\n"
                    ]
                  }
                }
              ],
              "request": {
                "method": "POST",
                "header": [
                  {
                    "key": "Content-Type",
                    "value": "application/fhir+json"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"resourceType\": \"Parameters\",\n  \"parameter\": []\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                },
                "url": {
                  "raw": "{{home_base_url}}/Patient/{{nina_patient_id}}/$everything",
                  "host": [
                    "{{home_base_url}}"
                  ],
                  "path": [
                    "Patient",
                    "{{nina_patient_id}}",
                    "$everything"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "3. $everything pagination next url",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "type": "text/javascript",
                    "exec": [
                      "pm.test('200 OK', () => pm.response.to.have.status(200));\nconst body = pm.response.json();\npm.test('FHIR Bundle', () => pm.expect(body.resourceType).to.eql('Bundle'));\npm.test('searchset type', () => pm.expect(body.type).to.eql('searchset'));\nconst hasPatient = (body.entry || []).some(e => e.resource && e.resource.resourceType === 'Patient');\npm.test('Bundle includes the Patient resource', () => pm.expect(hasPatient).to.be.true);"
                    ]
                  }
                }
              ],
              "protocolProfileBehavior": {
                "disableBodyPruning": true
              },
              "request": {
                "method": "GET",
                "header": [
                  {
                    "key": "Content-Type",
                    "value": "application/fhir+json"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"resourceType\": \"Parameters\",\n  \"parameter\": []\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                },
                "url": {
                  "raw": "{{next_link}}",
                  "host": [
                    "{{next_link}}"
                  ]
                }
              },
              "response": []
            }
          ],
          "description": "Non-local member who MATCHES on the Home plan. $member-match returns 200 + a MemberId whose Patient/{id} feeds the chained $everything. Drives the Host MatchedMembers bucket."
        },
        {
          "name": "Nonlocal Oscar — Opt-Out",
          "item": [
            {
              "name": "$member-match — 422 opt-out",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "type": "text/javascript",
                    "exec": [
                      "pm.test('422 Unprocessable Entity', () => pm.response.to.have.status(422));\nconst body = pm.response.json();\npm.test('OperationOutcome', () => pm.expect(body.resourceType).to.eql('OperationOutcome'));\nconst codes = (body.issue || []).map(i => i.code);\npm.test('issue.code signals opt-out (forbidden/suppressed/insufficient-consent)', () =>\n    pm.expect(codes.some(c => ['forbidden', 'suppressed', 'security'].includes(c)) || JSON.stringify(body).toLowerCase().includes('consent'),\n        'expected a consent/forbidden signal; got codes: ' + codes.join(',')).to.be.true);"
                    ]
                  }
                }
              ],
              "request": {
                "method": "POST",
                "header": [
                  {
                    "key": "Content-Type",
                    "value": "application/fhir+json"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"resourceType\": \"Parameters\",\n  \"parameter\": [\n    {\n      \"name\": \"MemberPatient\",\n      \"resource\": {\n        \"resourceType\": \"Patient\",\n        \"name\": [ { \"family\": \"Nonlocal\", \"given\": [ \"Oscar\" ] } ],\n        \"gender\": \"male\",\n        \"birthDate\": \"1982-07-22\"\n      }\n    },\n    {\n      \"name\": \"CoverageToMatch\",\n      \"resource\": {\n        \"resourceType\": \"Coverage\",\n        \"status\": \"active\",\n        \"identifier\": [\n          {\n            \"type\": {\n              \"coding\": [\n                {\n                  \"system\": \"http://terminology.hl7.org/CodeSystem/v2-0203\",\n                  \"code\": \"MB\",\n                  \"display\": \"Member Number\"\n                }\n              ]\n            },\n            \"system\": \"http://example.org/payer/member-id\",\n            \"value\": \"NON00002\"\n          }\n        ],\n        \"subscriberId\": \"NON00002\",\n        \"relationship\": { \"coding\": [ { \"system\": \"http://terminology.hl7.org/CodeSystem/subscriber-relationship\", \"code\": \"self\" } ] },\n        \"beneficiary\": { \"reference\": \"Patient/flowc-nonlocal-9002\", \"display\": \"Oscar Nonlocal\" },\n        \"payor\": [ { \"identifier\": { \"system\": \"http://hl7.org/fhir/sid/us-npi\", \"value\": \"1003100000\" } } ]\n      }\n    }\n  ]\n}\n",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                },
                "url": {
                  "raw": "{{home_base_url}}/Patient/$member-match",
                  "host": [
                    "{{home_base_url}}"
                  ],
                  "path": [
                    "Patient",
                    "$member-match"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "$everything — refused (opt-out)",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "type": "text/javascript",
                    "exec": [
                      "pm.test('export refused for opted-out member (422 or 404)', () =>\n    pm.expect([422, 404]).to.include(pm.response.code));\nconst body = pm.response.json();\npm.test('OperationOutcome', () => pm.expect(body.resourceType).to.eql('OperationOutcome'));"
                    ]
                  }
                }
              ],
              "request": {
                "method": "POST",
                "header": [
                  {
                    "key": "Content-Type",
                    "value": "application/fhir+json"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"resourceType\": \"Parameters\",\n  \"parameter\": []\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                },
                "url": {
                  "raw": "{{home_base_url}}/Patient/{{oscar_patient_id}}/$everything",
                  "host": [
                    "{{home_base_url}}"
                  ],
                  "path": [
                    "Patient",
                    "{{oscar_patient_id}}",
                    "$everything"
                  ]
                }
              },
              "response": []
            }
          ],
          "description": "Non-local member who has an active consent opt-out on the Home plan. $member-match returns 422 insufficient-consent (the Home plan is truthful). The Host is what MASKS this into NonMatchedMembers so the opt-out is not disclosed.\n\n$everything targets Oscar's known ingested Patient id (flowc-nonlocal-9002) directly to show export is ALSO refused for an opted-out member — no id is captured from the 422 above."
        }
      ],
      "description": "Home-plan HRex $member-match + PDex $everything, exercised per member.\n\nThese requests hit the Home plan DIRECTLY (not through the Host). Note the Home-plan HTTP response is not the same thing as the Host bucket:\n\n| Member | subscriberId | Home $member-match | Host bucket it drives |\n|--------|--------------|--------------------|-----------------------|\n| Nina Nonlocal | NON00001 | 200 + MemberId (match) | MatchedMembers |\n| Oscar Nonlocal | NON00002 | 422 insufficient-consent (opt-out) | NonMatchedMembers (Host MASKS the 422 as no-match) |\n\nOscar's 422 opt-out is truthful at the Home plan; the Host is what deliberately reclassifies a non-local opt-out into NonMatched so the opt-out isn't disclosed to the provider.",
      "auth": {
        "type": "oauth2",
        "oauth2": [
          {
            "key": "clientId",
            "value": "{{HOME_CLIENT_ID}}",
            "type": "string"
          },
          {
            "key": "accessTokenUrl",
            "value": "{{home_token_url}}",
            "type": "string"
          },
          {
            "key": "tokenName",
            "value": "Home Token",
            "type": "string"
          },
          {
            "key": "tokenType",
            "value": "Bearer",
            "type": "string"
          },
          {
            "key": "addTokenTo",
            "value": "header",
            "type": "string"
          },
          {
            "key": "clientSecret",
            "value": "{{HOME_CLIENT_SECRET}}",
            "type": "string"
          },
          {
            "key": "scope",
            "value": "{{home_scope}}",
            "type": "string"
          },
          {
            "key": "grant_type",
            "value": "client_credentials",
            "type": "string"
          }
        ]
      }
    }
  ],
  "auth": {
    "type": "oauth2",
    "oauth2": [
      {
        "key": "tokenType",
        "value": "Bearer",
        "type": "string"
      },
      {
        "key": "clientId",
        "value": "{{HOST_CLIENT_ID}}",
        "type": "string"
      },
      {
        "key": "accessTokenUrl",
        "value": "{{host_token_url}}",
        "type": "string"
      },
      {
        "key": "tokenName",
        "value": "Host Token",
        "type": "string"
      },
      {
        "key": "addTokenTo",
        "value": "header",
        "type": "string"
      },
      {
        "key": "clientSecret",
        "value": "{{HOST_CLIENT_SECRET}}",
        "type": "string"
      },
      {
        "key": "scope",
        "value": "{{host_scope}}",
        "type": "string"
      },
      {
        "key": "grant_type",
        "value": "client_credentials",
        "type": "string"
      }
    ]
  },
  "event": [
    {
      "listen": "prerequest",
      "script": {
        "type": "text/javascript",
        "packages": {},
        "requests": {},
        "exec": [
          ""
        ]
      }
    },
    {
      "listen": "test",
      "script": {
        "type": "text/javascript",
        "packages": {},
        "requests": {},
        "exec": [
          ""
        ]
      }
    }
  ],
  "variable": [
    {
      "key": "mm_task_id",
      "value": ""
    },
    {
      "key": "export_task_id",
      "value": ""
    },
    {
      "key": "nina_patient_id",
      "value": ""
    },
    {
      "key": "oscar_patient_id",
      "value": "flowc-nonlocal-9002"
    },
    {
      "key": "group_id",
      "value": ""
    },
    {
      "key": "everything_entry_total",
      "value": ""
    },
    {
      "key": "next_link",
      "value": ""
    },
    {
      "key": "matched_members_url",
      "value": ""
    },
    {
      "key": "non_matched_members_url",
      "value": ""
    },
    {
      "key": "consent_constrained_members_url",
      "value": ""
    },
    {
      "key": "member_match_parameters_url",
      "value": ""
    },
    {
      "key": "download_token_Patient",
      "value": ""
    },
    {
      "key": "download_token_Coverage",
      "value": ""
    },
    {
      "key": "download_token_Consent",
      "value": ""
    },
    {
      "key": "download_token_AllergyIntolerance",
      "value": ""
    },
    {
      "key": "download_token_CarePlan",
      "value": ""
    },
    {
      "key": "download_token_CareTeam",
      "value": ""
    },
    {
      "key": "download_token_Condition",
      "value": ""
    },
    {
      "key": "download_token_Device",
      "value": ""
    },
    {
      "key": "download_token_DiagnosticReport",
      "value": ""
    },
    {
      "key": "download_token_DocumentReference",
      "value": ""
    },
    {
      "key": "download_token_Encounter",
      "value": ""
    },
    {
      "key": "download_token_Goal",
      "value": ""
    },
    {
      "key": "download_token_Immunization",
      "value": ""
    },
    {
      "key": "download_token_MedicationDispense",
      "value": ""
    },
    {
      "key": "download_token_MedicationRequest",
      "value": ""
    },
    {
      "key": "download_token_Observation",
      "value": ""
    },
    {
      "key": "download_token_Procedure",
      "value": ""
    },
    {
      "key": "download_token_Provenance",
      "value": ""
    },
    {
      "key": "download_token_QuestionnaireResponse",
      "value": ""
    },
    {
      "key": "download_token_RelatedPerson",
      "value": ""
    },
    {
      "key": "download_token_ServiceRequest",
      "value": ""
    },
    {
      "key": "download_token_Specimen",
      "value": ""
    },
    {
      "key": "download_token_ExplanationOfBenefit",
      "value": ""
    },
    {
      "key": "download_token_Practitioner",
      "value": ""
    },
    {
      "key": "download_token_PractitionerRole",
      "value": ""
    },
    {
      "key": "download_token_Organization",
      "value": ""
    },
    {
      "key": "download_token_Location",
      "value": ""
    },
    {
      "key": "download_token_Medication",
      "value": ""
    }
  ]
}